diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index 4772676754ca..d0498443d204 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -91,7 +91,6 @@ #include "nsITreeContentView.h" #include "nsITreeView.h" #include "nsIXULTemplateBuilder.h" -#include "nsITreeColumns.h" #endif #include "nsIDOMXPathNSResolver.h" @@ -265,11 +264,6 @@ static nsDOMClassInfoData sClassInfoData[] = { DEFAULT_SCRIPTABLE_FLAGS) #endif -#ifdef MOZ_XUL - NS_DEFINE_CHROME_XBL_CLASSINFO_DATA(TreeColumn, nsDOMGenericSH, - DEFAULT_SCRIPTABLE_FLAGS) -#endif - NS_DEFINE_CLASSINFO_DATA(CSSMozDocumentRule, nsDOMGenericSH, DOM_DEFAULT_SCRIPTABLE_FLAGS) @@ -716,12 +710,6 @@ nsDOMClassInfo::Init() DOM_CLASSINFO_MAP_END #endif -#ifdef MOZ_XUL - DOM_CLASSINFO_MAP_BEGIN(TreeColumn, nsITreeColumn) - DOM_CLASSINFO_MAP_ENTRY(nsITreeColumn) - DOM_CLASSINFO_MAP_END -#endif - DOM_CLASSINFO_MAP_BEGIN(CSSMozDocumentRule, nsIDOMCSSMozDocumentRule) DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSMozDocumentRule) DOM_CLASSINFO_MAP_END diff --git a/dom/base/nsDOMClassInfoClasses.h b/dom/base/nsDOMClassInfoClasses.h index 0749b14cfb84..f6e15ccf382a 100644 --- a/dom/base/nsDOMClassInfoClasses.h +++ b/dom/base/nsDOMClassInfoClasses.h @@ -29,10 +29,6 @@ DOMCI_CLASS(XULTemplateBuilder) DOMCI_CLASS(XULTreeBuilder) #endif -#ifdef MOZ_XUL -DOMCI_CLASS(TreeColumn) -#endif - DOMCI_CLASS(CSSMozDocumentRule) DOMCI_CLASS(CSSSupportsRule) diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index 5558641b6c2d..8b4cd8943a75 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -1212,6 +1212,11 @@ DOMInterfaces = { 'headerFile': 'mozilla/dom/TouchEvent.h', }, +'TreeColumn': { + 'nativeType': 'nsTreeColumn', + 'headerFile': 'nsTreeColumns.h', +}, + 'TreeColumns': { 'nativeType': 'nsTreeColumns', }, @@ -1820,8 +1825,6 @@ addExternalIface('MozRDFCompositeDataSource', nativeType='nsIRDFCompositeDataSou notflattened=True) addExternalIface('MozRDFResource', nativeType='nsIRDFResource', notflattened=True) addExternalIface('MozSmsMessage') -addExternalIface('MozTreeColumn', nativeType='nsITreeColumn', - headerFile='nsITreeColumns.h') addExternalIface('MozTreeView', nativeType='nsITreeView', headerFile='nsITreeView.h') addExternalIface('MozWakeLockListener', headerFile='nsIDOMWakeLockListener.h') diff --git a/dom/webidl/TreeBoxObject.webidl b/dom/webidl/TreeBoxObject.webidl index 47760c7e41b2..8ca0a571384d 100644 --- a/dom/webidl/TreeBoxObject.webidl +++ b/dom/webidl/TreeBoxObject.webidl @@ -6,12 +6,11 @@ */ interface MozTreeView; -interface MozTreeColumn; interface nsIScriptableRegion; dictionary TreeCellInfo { long row = 0; - MozTreeColumn? col = null; + TreeColumn? col = null; DOMString childElt = ""; }; @@ -84,7 +83,7 @@ interface TreeBoxObject : BoxObject { /** * Ensures that a given cell in the tree is visible. */ - void ensureCellIsVisible(long row, MozTreeColumn? col); + void ensureCellIsVisible(long row, TreeColumn? col); /** * Scrolls such that the row at index is at the top of the visible view. @@ -110,13 +109,13 @@ interface TreeBoxObject : BoxObject { * Scrolls such that a given cell is visible (if possible) * at the top left corner of the visible view. */ - void scrollToCell(long row, MozTreeColumn? col); + void scrollToCell(long row, TreeColumn? col); /** * Scrolls horizontally so that the specified column is * at the left of the view (if possible). */ - void scrollToColumn(MozTreeColumn? col); + void scrollToColumn(TreeColumn? col); /** * Scroll to a specific horizontal pixel position. @@ -127,11 +126,11 @@ interface TreeBoxObject : BoxObject { * Invalidation methods for fine-grained painting control. */ void invalidate(); - void invalidateColumn(MozTreeColumn? col); + void invalidateColumn(TreeColumn? col); void invalidateRow(long index); - void invalidateCell(long row, MozTreeColumn? col); + void invalidateCell(long row, TreeColumn? col); void invalidateRange(long startIndex, long endIndex); - void invalidateColumnRange(long startIndex, long endIndex, MozTreeColumn? col); + void invalidateColumnRange(long startIndex, long endIndex, TreeColumn? col); /** * A hit test that can tell you what row the mouse is over. @@ -165,20 +164,20 @@ interface TreeBoxObject : BoxObject { * Find the coordinates of an element within a specific cell. */ [Throws] - DOMRect? getCoordsForCellItem(long row, MozTreeColumn col, DOMString element); + DOMRect? getCoordsForCellItem(long row, TreeColumn col, DOMString element); /** * DEPRECATED: Please use above version */ [Throws] - void getCoordsForCellItem(long row, MozTreeColumn col, DOMString element, + void getCoordsForCellItem(long row, TreeColumn col, DOMString element, object x, object y, object width, object height); /** * Determine if the text of a cell is being cropped or not. */ [Throws] - boolean isCellCropped(long row, MozTreeColumn? col); + boolean isCellCropped(long row, TreeColumn? col); /** * The view is responsible for calling these notification methods when diff --git a/dom/webidl/TreeColumn.webidl b/dom/webidl/TreeColumn.webidl new file mode 100644 index 000000000000..a4e02f5791e3 --- /dev/null +++ b/dom/webidl/TreeColumn.webidl @@ -0,0 +1,35 @@ +/* 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/. */ + +[Func="IsChromeOrXBL"] +interface TreeColumn { + [Throws] + readonly attribute Element? element; + + readonly attribute TreeColumns? columns; + + [Throws] + readonly attribute long x; + [Throws] + readonly attribute long width; + + readonly attribute DOMString id; + 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_PROGRESSMETER = 3; + readonly attribute short type; + + TreeColumn? getNext(); + TreeColumn? getPrevious(); + + [Throws] + void invalidate(); +}; diff --git a/dom/webidl/TreeColumns.webidl b/dom/webidl/TreeColumns.webidl index a6ff9e07b56b..5958d1235229 100644 --- a/dom/webidl/TreeColumns.webidl +++ b/dom/webidl/TreeColumns.webidl @@ -2,8 +2,6 @@ * 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/. */ -interface MozTreeColumn; - [Func="IsChromeOrXBL"] interface TreeColumns { /** @@ -25,26 +23,26 @@ interface TreeColumns { /** * Get the first/last column. */ - MozTreeColumn? getFirstColumn(); - MozTreeColumn? getLastColumn(); + TreeColumn? getFirstColumn(); + TreeColumn? getLastColumn(); /** * Attribute based column getters. */ - MozTreeColumn? getPrimaryColumn(); - MozTreeColumn? getSortedColumn(); - MozTreeColumn? getKeyColumn(); + TreeColumn? getPrimaryColumn(); + TreeColumn? getSortedColumn(); + TreeColumn? getKeyColumn(); /** * Get the column for the given element. */ - MozTreeColumn? getColumnFor(Element? element); + TreeColumn? getColumnFor(Element? element); /** * Parametric column getters. */ - getter MozTreeColumn? getNamedColumn(DOMString name); - getter MozTreeColumn? getColumnAt(unsigned long index); + getter TreeColumn? getNamedColumn(DOMString name); + getter TreeColumn? getColumnAt(unsigned long index); /** * This method is called whenever a treecol is added or removed and diff --git a/dom/webidl/moz.build b/dom/webidl/moz.build index 8c950a00f08c..c0f78bf194d6 100644 --- a/dom/webidl/moz.build +++ b/dom/webidl/moz.build @@ -498,6 +498,7 @@ WEBIDL_FILES = [ 'TouchList.webidl', 'TransitionEvent.webidl', 'TreeBoxObject.webidl', + 'TreeColumn.webidl', 'TreeColumns.webidl', 'TreeWalker.webidl', 'UDPMessageEvent.webidl', diff --git a/layout/xul/tree/TreeBoxObject.cpp b/layout/xul/tree/TreeBoxObject.cpp index a52200d8846a..25a1f3cfcde6 100644 --- a/layout/xul/tree/TreeBoxObject.cpp +++ b/layout/xul/tree/TreeBoxObject.cpp @@ -521,7 +521,9 @@ TreeBoxObject::GetCellAt(int32_t aX, int32_t aY, int32_t *aRow, void TreeBoxObject::GetCellAt(int32_t x, int32_t y, TreeCellInfo& aRetVal, ErrorResult& aRv) { - GetCellAt(x, y, &aRetVal.mRow, getter_AddRefs(aRetVal.mCol), aRetVal.mChildElt); + nsCOMPtr col; + GetCellAt(x, y, &aRetVal.mRow, getter_AddRefs(col), aRetVal.mChildElt); + aRetVal.mCol = col.forget().downcast(); } void @@ -569,10 +571,10 @@ TreeBoxObject::GetCoordsForCellItem(int32_t aRow, nsITreeColumn* aCol, const nsA } already_AddRefed -TreeBoxObject::GetCoordsForCellItem(int32_t row, nsITreeColumn* col, const nsAString& element, ErrorResult& aRv) +TreeBoxObject::GetCoordsForCellItem(int32_t row, nsTreeColumn& col, const nsAString& element, ErrorResult& aRv) { int32_t x, y, w, h; - GetCoordsForCellItem(row, col, element, &x, &y, &w, &h); + GetCoordsForCellItem(row, &col, element, &x, &y, &w, &h); nsRefPtr rect = new DOMRect(mContent, x, y, w, h); return rect.forget(); } @@ -580,7 +582,7 @@ TreeBoxObject::GetCoordsForCellItem(int32_t row, nsITreeColumn* col, const nsASt void TreeBoxObject::GetCoordsForCellItem(JSContext* cx, int32_t row, - nsITreeColumn* col, + nsTreeColumn& col, const nsAString& element, JS::Handle xOut, JS::Handle yOut, @@ -589,7 +591,7 @@ TreeBoxObject::GetCoordsForCellItem(JSContext* cx, ErrorResult& aRv) { int32_t x, y, w, h; - GetCoordsForCellItem(row, col, element, &x, &y, &w, &h); + GetCoordsForCellItem(row, &col, element, &x, &y, &w, &h); JS::Rooted v(cx, INT_TO_JSVAL(x)); if (!JS_SetProperty(cx, xOut, "value", v)) { aRv.Throw(NS_ERROR_XPC_CANT_SET_OUT_VAL); diff --git a/layout/xul/tree/TreeBoxObject.h b/layout/xul/tree/TreeBoxObject.h index 3dff84ad6ecb..9c5bff2ba756 100644 --- a/layout/xul/tree/TreeBoxObject.h +++ b/layout/xul/tree/TreeBoxObject.h @@ -11,6 +11,7 @@ #include "nsITreeBoxObject.h" class nsTreeBodyFrame; +class nsTreeColumn; class nsTreeColumns; namespace mozilla { @@ -68,7 +69,7 @@ public: void GetCellAt(int32_t x, int32_t y, TreeCellInfo& aRetVal, ErrorResult& aRv); already_AddRefed GetCoordsForCellItem(int32_t row, - nsITreeColumn* col, + nsTreeColumn& col, const nsAString& element, ErrorResult& aRv); @@ -84,7 +85,7 @@ public: void GetCoordsForCellItem(JSContext* cx, int32_t row, - nsITreeColumn* col, + nsTreeColumn& col, const nsAString& element, JS::Handle xOut, JS::Handle yOut, diff --git a/layout/xul/tree/moz.build b/layout/xul/tree/moz.build index 4144b4e8730f..ed335e65e8b8 100644 --- a/layout/xul/tree/moz.build +++ b/layout/xul/tree/moz.build @@ -16,6 +16,7 @@ XPIDL_MODULE = 'layout_xul_tree' EXPORTS += [ 'nsTreeColFrame.h', + 'nsTreeColumns.h', 'nsTreeUtils.h', ] diff --git a/layout/xul/tree/nsTreeColumns.cpp b/layout/xul/tree/nsTreeColumns.cpp index be2ff743d3a9..03a1d595958c 100644 --- a/layout/xul/tree/nsTreeColumns.cpp +++ b/layout/xul/tree/nsTreeColumns.cpp @@ -15,6 +15,7 @@ #include "nsTreeBodyFrame.h" #include "mozilla/dom/Element.h" #include "mozilla/dom/TreeBoxObject.h" +#include "mozilla/dom/TreeColumnBinding.h" #include "mozilla/dom/TreeColumnsBinding.h" using namespace mozilla; @@ -43,6 +44,7 @@ nsTreeColumn::~nsTreeColumn() NS_IMPL_CYCLE_COLLECTION_CLASS(nsTreeColumn) NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsTreeColumn) + NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER NS_IMPL_CYCLE_COLLECTION_UNLINK(mContent) if (tmp->mNext) { tmp->mNext->SetPrevious(nullptr); @@ -52,18 +54,18 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsTreeColumn) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mContent) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mNext) + NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS 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) -DOMCI_DATA(TreeColumn, 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_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(TreeColumn) if (aIID.Equals(NS_GET_IID(nsTreeColumn))) { AddRef(); *aInstancePtr = this; @@ -344,6 +346,51 @@ nsTreeColumn::Invalidate() return NS_OK; } +nsIContent* +nsTreeColumn::GetParentObject() const +{ + return mContent; +} + +/* virtual */ JSObject* +nsTreeColumn::WrapObject(JSContext* aCx) +{ + return dom::TreeColumnBinding::Wrap(aCx, this); +} + +mozilla::dom::Element* +nsTreeColumn::GetElement(mozilla::ErrorResult& aRv) +{ + nsCOMPtr element; + aRv = GetElement(getter_AddRefs(element)); + if (aRv.Failed()) { + return nullptr; + } + nsCOMPtr node = do_QueryInterface(element); + return node->AsElement(); +} + +int32_t +nsTreeColumn::GetX(mozilla::ErrorResult& aRv) +{ + int32_t x; + aRv = GetX(&x); + return x; +} + +int32_t +nsTreeColumn::GetWidth(mozilla::ErrorResult& aRv) +{ + int32_t width; + aRv = GetWidth(&width); + return width; +} + +void +nsTreeColumn::Invalidate(mozilla::ErrorResult& aRv) +{ + aRv = Invalidate(); +} nsTreeColumns::nsTreeColumns(nsTreeBodyFrame* aTree) : mTree(aTree), diff --git a/layout/xul/tree/nsTreeColumns.h b/layout/xul/tree/nsTreeColumns.h index dad67dcb06bc..956900eb9a61 100644 --- a/layout/xul/tree/nsTreeColumns.h +++ b/layout/xul/tree/nsTreeColumns.h @@ -22,6 +22,7 @@ class nsIContent; struct nsRect; namespace mozilla { +class ErrorResult; namespace dom { class Element; class TreeBoxObject; @@ -38,16 +39,43 @@ class TreeBoxObject; // This class is our column info. We use it to iterate our columns and to obtain // information about each column. -class nsTreeColumn MOZ_FINAL : public nsITreeColumn { +class nsTreeColumn MOZ_FINAL : public nsITreeColumn + , public nsWrapperCache +{ public: nsTreeColumn(nsTreeColumns* aColumns, nsIContent* aContent); NS_DECLARE_STATIC_IID_ACCESSOR(NS_TREECOLUMN_IMPL_CID) NS_DECL_CYCLE_COLLECTING_ISUPPORTS - NS_DECL_CYCLE_COLLECTION_CLASS(nsTreeColumn) + NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsTreeColumn) NS_DECL_NSITREECOLUMN + // WebIDL + nsIContent* GetParentObject() const; + virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE; + + mozilla::dom::Element* GetElement(mozilla::ErrorResult& aRv); + + nsTreeColumns* GetColumns() const { return mColumns; } + + int32_t GetX(mozilla::ErrorResult& aRv); + int32_t GetWidth(mozilla::ErrorResult& aRv); + + // GetId is fine + 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; } + + nsTreeColumn* GetNext() const { return mNext; } + nsTreeColumn* GetPrevious() const { return mPrevious; } + + void Invalidate(mozilla::ErrorResult& aRv); + friend class nsTreeBodyFrame; friend class nsTreeColumns; @@ -86,8 +114,6 @@ protected: int8_t GetCropStyle() { return mCropStyle; } int32_t GetTextAlignment() { return mTextAlignment; } - nsTreeColumn* GetNext() { return mNext; } - nsTreeColumn* GetPrevious() { return mPrevious; } void SetNext(nsTreeColumn* aNext) { NS_ASSERTION(!mNext, "already have a next sibling"); mNext = aNext;