зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1081692 - Move TreeColumn to WebIDL. r=khuey
--HG-- rename : layout/xul/tree/nsITreeColumns.idl => dom/webidl/TreeColumn.webidl
This commit is contained in:
Родитель
ded882fb2a
Коммит
a3ee1b5004
|
@ -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
|
||||
|
|
|
@ -29,10 +29,6 @@ DOMCI_CLASS(XULTemplateBuilder)
|
|||
DOMCI_CLASS(XULTreeBuilder)
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_XUL
|
||||
DOMCI_CLASS(TreeColumn)
|
||||
#endif
|
||||
|
||||
DOMCI_CLASS(CSSMozDocumentRule)
|
||||
DOMCI_CLASS(CSSSupportsRule)
|
||||
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
};
|
|
@ -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
|
||||
|
|
|
@ -498,6 +498,7 @@ WEBIDL_FILES = [
|
|||
'TouchList.webidl',
|
||||
'TransitionEvent.webidl',
|
||||
'TreeBoxObject.webidl',
|
||||
'TreeColumn.webidl',
|
||||
'TreeColumns.webidl',
|
||||
'TreeWalker.webidl',
|
||||
'UDPMessageEvent.webidl',
|
||||
|
|
|
@ -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<nsITreeColumn> col;
|
||||
GetCellAt(x, y, &aRetVal.mRow, getter_AddRefs(col), aRetVal.mChildElt);
|
||||
aRetVal.mCol = col.forget().downcast<nsTreeColumn>();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -569,10 +571,10 @@ TreeBoxObject::GetCoordsForCellItem(int32_t aRow, nsITreeColumn* aCol, const nsA
|
|||
}
|
||||
|
||||
already_AddRefed<DOMRect>
|
||||
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<DOMRect> 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<JSObject*> xOut,
|
||||
JS::Handle<JSObject*> 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<JS::Value> v(cx, INT_TO_JSVAL(x));
|
||||
if (!JS_SetProperty(cx, xOut, "value", v)) {
|
||||
aRv.Throw(NS_ERROR_XPC_CANT_SET_OUT_VAL);
|
||||
|
|
|
@ -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<DOMRect> 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<JSObject*> xOut,
|
||||
JS::Handle<JSObject*> yOut,
|
||||
|
|
|
@ -16,6 +16,7 @@ XPIDL_MODULE = 'layout_xul_tree'
|
|||
|
||||
EXPORTS += [
|
||||
'nsTreeColFrame.h',
|
||||
'nsTreeColumns.h',
|
||||
'nsTreeUtils.h',
|
||||
]
|
||||
|
||||
|
|
|
@ -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<nsIDOMElement> element;
|
||||
aRv = GetElement(getter_AddRefs(element));
|
||||
if (aRv.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
nsCOMPtr<nsINode> 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),
|
||||
|
|
|
@ -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;
|
||||
|
|
Загрузка…
Ссылка в новой задаче