Source code

Revision control

Other Tools

1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
3
/* This Source Code Form is subject to the terms of the Mozilla Public
4
* License, v. 2.0. If a copy of the MPL was not distributed with this
5
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
#ifndef XULTreeElement_h__
8
#define XULTreeElement_h__
9
10
#include "mozilla/Attributes.h"
11
#include "mozilla/ErrorResult.h"
12
#include "nsCycleCollectionParticipant.h"
13
#include "nsWrapperCache.h"
14
#include "nsString.h"
15
#include "nsXULElement.h"
16
#include "nsITreeView.h"
17
18
class nsTreeBodyFrame;
19
class nsTreeColumn;
20
class nsTreeColumns;
21
22
namespace mozilla {
23
namespace dom {
24
25
struct TreeCellInfo;
26
class DOMRect;
27
enum class CallerType : uint32_t;
28
29
class XULTreeElement final : public nsXULElement {
30
public:
31
explicit XULTreeElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
32
: nsXULElement(std::move(aNodeInfo)),
33
mCachedFirstVisibleRow(0),
34
mTreeBody(nullptr) {}
35
36
NS_IMPL_FROMNODE_WITH_TAG(XULTreeElement, kNameSpaceID_XUL, tree)
37
38
NS_DECL_ISUPPORTS_INHERITED
39
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(XULTreeElement, nsXULElement)
40
41
nsTreeBodyFrame* GetTreeBodyFrame(FlushType = FlushType::Frames);
42
nsTreeBodyFrame* GetCachedTreeBodyFrame() { return mTreeBody; }
43
44
already_AddRefed<nsTreeColumns> GetColumns();
45
46
already_AddRefed<nsITreeView> GetView(CallerType /* unused */) {
47
return GetView();
48
}
49
already_AddRefed<nsITreeView> GetView();
50
51
void SetView(nsITreeView* arg, CallerType aCallerType, ErrorResult& aRv);
52
53
bool Focused();
54
55
already_AddRefed<Element> GetTreeBody();
56
57
int32_t RowHeight();
58
59
int32_t RowWidth();
60
61
int32_t HorizontalPosition();
62
63
void EnsureCellIsVisible(int32_t row, nsTreeColumn* col, ErrorResult& aRv);
64
65
void ScrollToRow(int32_t aRow);
66
67
void ScrollByLines(int32_t aNumLines);
68
69
void ScrollByPages(int32_t aNumPages);
70
71
int32_t GetFirstVisibleRow();
72
73
int32_t GetLastVisibleRow();
74
75
int32_t GetPageLength();
76
77
int32_t GetRowAt(int32_t x, int32_t y);
78
79
void GetCellAt(int32_t x, int32_t y, TreeCellInfo& aRetVal, ErrorResult& aRv);
80
81
nsIntRect GetCoordsForCellItem(int32_t aRow, nsTreeColumn* aCol,
82
const nsAString& aElement, nsresult& rv);
83
already_AddRefed<DOMRect> GetCoordsForCellItem(int32_t row, nsTreeColumn& col,
84
const nsAString& element,
85
ErrorResult& aRv);
86
87
bool IsCellCropped(int32_t row, nsTreeColumn* col, ErrorResult& aRv);
88
89
void RemoveImageCacheEntry(int32_t row, nsTreeColumn& col, ErrorResult& aRv);
90
91
void SetFocused(bool aFocused);
92
void EnsureRowIsVisible(int32_t index);
93
void Invalidate(void);
94
void InvalidateColumn(nsTreeColumn* col);
95
void InvalidateRow(int32_t index);
96
void InvalidateCell(int32_t row, nsTreeColumn* col);
97
void InvalidateRange(int32_t startIndex, int32_t endIndex);
98
void RowCountChanged(int32_t index, int32_t count);
99
void BeginUpdateBatch(void);
100
void EndUpdateBatch(void);
101
void ClearStyleAndImageCaches(void);
102
103
virtual void UnbindFromTree(bool aNullParent) override;
104
virtual void DestroyContent() override;
105
106
void BodyDestroyed(int32_t aFirstVisibleRow) {
107
mTreeBody = nullptr;
108
mCachedFirstVisibleRow = aFirstVisibleRow;
109
}
110
111
int32_t GetCachedTopVisibleRow() { return mCachedFirstVisibleRow; }
112
113
protected:
114
int32_t mCachedFirstVisibleRow;
115
116
nsTreeBodyFrame* mTreeBody;
117
nsCOMPtr<nsITreeView> mView;
118
119
virtual ~XULTreeElement() {}
120
121
JSObject* WrapNode(JSContext* aCx,
122
JS::Handle<JSObject*> aGivenProto) override;
123
};
124
125
} // namespace dom
126
} // namespace mozilla
127
128
#endif